<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1.0,minimum-scale=1.0,user-scalable=no"/>
  <meta name="format-detection" content="telephone=no, email=no"/>
  <!-- 忽略页面中的数字识别为电话，忽略email识别 -->
  <meta name="applicable-device" content="mobile"/>
  <meta name="apple-mobile-web-app-title" content="标题"/>
  <!-- 添加到主屏后的标题（iOS 6 新增） -->
  <meta name="apple-mobile-web-app-capable" content="yes"/>
  <!-- 是否启用 WebApp 全屏模式 -->
  <meta name="HandheldFriendly" content="true"/>
  <!-- 针对手持设备优化，主要是针对一些老的不识别viewport的浏览器，比如黑莓 -->
  <meta name="keywords" content="直播盐都"/>
  <meta name="description" content="直播盐都"/>
  <meta name="cl">
  <title>${(info.refLive.title?j_string)!}</title>
  <link rel="stylesheet" type="text/css" href="${ctx}/sctv/h5/css/globle.css">
  <script src="${ctx}/sctv/h5/js/jquery-1.8.3.min.js" type="text/javascript"></script>
  <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
  <script type="text/javascript" src="http://qzonestyle.gtimg.cn/qzone/qzact/common/share/share.js"></script>
  <script type="text/javascript" src="${ctx}/sctv/h5/js/senShare.js"></script>
</head>
<body>
<!--video s-->
<div class="ground_video">
  <div class="imgBg"></div>
  <input id="liveRom" value="${(info.refLive.id)!}" style="display: none">
 <input type="hidden" value="${(info.refLive.status)!}" id="liveStatus" style="display: none">
  <p class="living"></p>
  <video id="video" class="videoBox" poster="http://192.168.81.70:8080${(info.refLive.image)!}" src="[#if info.refLive.status==2]${(info.refLive.fLookBack)!}[/#if][#if info.refLive.status!=2]${(info.refLive.taddress)!}[/#if]" controls></video>
  <!--    <i class="iconFont" onclick="videoPlay('video')"></i>-->
</div>
<!--video e-->
<!--简介 s-->
<p class="liveSource">直播来源:${(info.refLive.source)!}<span class="fr">${(info.refLive.createtime?string('MM-dd'))!}</span></p>
<div class="liveKg">
  <span class="fl">简介：</span>
  <p>${(info.refLive.introduction?j_string)!}</p>
</div>
<!--简介 e-->
<!--直播聊天室 s-->
<div>
  <ol class="liveChoose clearfix">
    <li class="fl on" id="d1">直播间<label></label></li>
    <li class="fr" id="d2">聊天室<label></label></li>
  </ol>

  <div  id="d1d">
  <ul class="liveCont">

  </ul>
</div>
<div class="descComment" style="display: none" id="d2d">
  <ul><p class='notHaveData'>暂无相关内容</p></ul>
</div>
</div>
<!--直播聊天室 e-->
<!--底部 s-->
<div class="pdDownLoad">
  <img class="pdlogo1 fl" src="${ctx}/sctv/h5/images/down_word.png" alt="">
  <a class="pdlogo2 fl" href="http://a.app.qq.com/o/simple.jsp?pkgname=com.sctv.scfocus"> <img src="${ctx}/sctv/h5/images/down.png"
                                                                                               alt=""> </a>
  <img onclick="colseTan()" class="pdlogo3 fl" src="${ctx}/sctv/h5/images/close.png" alt="">
</div>
<!--底部 e-->


<script src="${ctx}/sctv/h5/js/main.js" type="text/javascript"></script>
<script>
  const img = "http://192.168.81.70:8080";
  $(function () {
    //如果视频没有src则去除播放控件
    if($('#video').attr('src') == ''){
      $('#video').removeAttr('controls')
    }
    var id = $("#liveRom").val();
    //getVideo();
    //视频比例
    ban_s(".ground_video");
    $(".liveChoose li").click(function () {
      $(this).addClass('on').siblings().removeClass('on');
      var val = $(this).attr("id");
      if (val == "d1") {
        $("#d1d").show();
        $("#d2d").hide();
      } else {
        $("#d1d").hide();
        $("#d2d").show();
      }
    })
    loadComment(id);
    loadLive(id);
    addClickRate(id);
  });
  /*加载评论*/
  function loadComment(id) {
    try {
      $.ajax({
        url: 'http://192.168.81.71:8083/getChatCommentList',
        type: 'POST',
        data: {liveId: id},
        success: function (dataStr) {
          console.log("请求完成")
          var data = JSON.parse(dataStr);
          var lis = data.data.commentList;
          var html = "";
          for (var v = 0; v < lis.length; v++) {
            html += '<li>'
                + '<div class="CommentTx">'
                + ' <p class="fl"><img src="' + img + lis[v].avatar + '" alt=""></p>'
                + ' <span>' + lis[v].nickName + '</span>'
                + ' </div>'
                + ' <p class="CommentPc">'+lis[v].comment+'</p>'
                + ' </li>';
          }
          console.log(html);
          $(".descComment ul").html(html);
        }
      });
    } catch (err) {
      console.log(err)
      $(".descComment ul").html("<p class='notHaveData'>暂无相关评论</p>");
    }

  }
  //加载直播间
  function loadLive(id) {
    try {
      $.ajax({
        url: 'http://192.168.81.71:8083/liveroom',
        type: 'POST',
        data: {roomid: id},
        success: function (dataStr) {
          var data = JSON.parse(dataStr);
          var lis = data.data.list;
		  var liveType=$("#liveStatus").val();//获取直播状态 2直播回顾
		  if(liveType==2){//直播回顾需要倒序
		  lis=lis.reverse();
		  $(".living").hide();
		  }
          var html = "";
          for (var v = 0; v <lis.length; v++) {
            var video = lis[v].video;
            var videoHtml = "";
            var imgHtml = " ";
            if (null != video && "" != video && "undefined" != typeof video) {
              var videoImg=lis[v].image;
              if(null != videoImg && "" != videoImg && "undefined" != typeof videoImg){
                if(videoImg.endsWith(",")){
                  videoImg=videoImg.substring(0,videoImg.length-1)
                }
                videoHtml = '<video id="v" class="videoBox" src="' + video + '" controls poster="' +img+ videoImg + '"></video>';
              }
            } else {
              var im = lis[v].image;
              if (null != im && "" != im && "undefined" != typeof im) {
                if(typeof im !="string"){
                  im=im+"";
                }
                if(im.endsWith(",")){
                  im=im.substring(0,im.length-1)
                }
                var imgs = (im + "").split(",");
                if (imgs.length == 1) {//一张图

                  imgHtml += "<div class='scaleBg' onclick='scalsClose(this,1)'><img onclick='scaleFun(this,event,1)' src='" + img + imgs[0] + "' alt=' ' style='width:100%;height:auto'></div>";
                } else {//多张图
                  for (var a = 0; a < imgs.length; a++) {
                    imgHtml += "<div class='scaleBg' onclick='scalsClose(this,0)'><img onclick='scaleFun(this,event,0)' src='" + img + imgs[a] + "' alt=''></div>";

                  }
                }
              }
            }


            html += '<li class="clearfix">'
                +' <span>'+datetimeFormat_1(lis[v].time)+'</span>'
                +'    <p>'+lis[v].content+'</p>'
                +   videoHtml
                +   imgHtml
                +'    <label></label>'
                +'    <hr>'
                +'</li>';
          }


          $(".liveCont").html(html);
        }
      });
    } catch (err) {
      $(".liveCont").html("<p class='notHaveData'>暂无相关内容</p>");
    }
  }

  function datetimeFormat_1(longTypeDate) {
    var datetimeType = "";
    var date = new Date();
    date.setTime(longTypeDate);
    datetimeType += date.getFullYear();   //年
    datetimeType += "-" + getMonth(date); //月
    datetimeType += "-" + getDay(date);   //日
    datetimeType += "&nbsp;&nbsp;" + getHours(date);   //时
    datetimeType += ":" + getMinutes(date);      //分
    datetimeType += ":" + getSeconds(date);      //分
    return datetimeType;
  }
  //返回 01-12 的月份值
  function getMonth(date) {
    var month = "";
    month = date.getMonth() + 1; //getMonth()得到的月份是0-11
    if (month < 10) {
      month = "0" + month;
    }
    return month;
  }
  //返回01-30的日期
  function getDay(date) {
    var day = "";
    day = date.getDate();
    if (day < 10) {
      day = "0" + day;
    }
    return day;
  }
  //返回小时
  function getHours(date) {
    var hours = "";
    hours = date.getHours();
    if (hours < 10) {
      hours = "0" + hours;
    }
    return hours;
  }
  //返回分
  function getMinutes(date) {
    var minute = "";
    minute = date.getMinutes();
    if (minute < 10) {
      minute = "0" + minute;
    }
    return minute;
  }
  //返回秒
  function getSeconds(date) {
    var second = "";
    second = date.getSeconds();
    if (second < 10) {
      second = "0" + second;
    }
    return second;
  }
  /*分享页点击量点击量*/
  function addClickRate(newsId) {
      $.ajax({
          url: 'http://192.168.81.71:8083/addShareViews',
          type: 'POST',
          crossDomain: true,
          data: {type: 1,id:newsId},
          success: function (dataStr) {
              console.log(dataStr)
          }
      });

  }
</script>
</body>
</html>
